package com.euond.permission.controller;

import com.euond.common.core.dto.ResultDto;
import com.euond.common.web.controller.BaseCRUDController;
import com.euond.permission.entities.Menu;
import com.euond.permission.service.MenuService;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * Created by user on 2017/7/25.
 */
@RestController
@RequestMapping("permission/front/menus")
public class MenuController extends BaseCRUDController<MenuService,Menu> {

    /**
     * 首页按项目加载菜单
     */
    @GetMapping(value = "project/menu")
    public ResultDto findProjectMenus(@RequestParam("projectId") Long projectId, @RequestParam("companyId") Long companyId, @RequestParam("userId") Long userId) {
        return baseService.findMenus(projectId, companyId,userId);
    }

    /**
     * 菜单管理中加载菜单（无需进行用户权限过滤）
     */
    @GetMapping(value = "project/menu/nopermission")
    public ResultDto findProjectMenusNoPermission(@RequestParam("projectId") Long projectId, @RequestParam("companyId") Long companyId) {
        return baseService.findMenus(projectId, companyId,null);
    }

    /**
     * 按项目查找未分配菜单的资源
     */
    @GetMapping(value = "menu/no/resource")
    public ResultDto findMenuNoResource(@RequestParam Map<String,Object> searchParams) {
        return baseService.findNotAllotMenuResources(searchParams);
    }
}
